﻿using BaoGiaVeThang.DAL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BaoGiaVeThang
{
    class ListDomesticRoute
    {
        private static DomesticRoute[] _listDomesticRoute = null;
        public static DomesticRoute[] getListDomesticRoute()
        {
            if (_listDomesticRoute == null)
            {
                DataTable dt = DBHelper.GetDataTableSP("GetDomesticRoute");
                List<DomesticRoute> li = new List<DomesticRoute>();
                foreach(DataRow dr in dt.Rows)
                {
                    DomesticRoute dmr = new DomesticRoute();
                    dmr.Id=(int)dr["Id"];
                    dmr.IsBL=(bool)dr["IsBL"];
                    dmr.IsVJ=(bool)dr["IsVJ"];
                    dmr.IsVN=(bool)dr["IsVN"];
                    dmr.ArrivalAirport = (string)dr["ArrivalAirport"];
                    dmr.DepartureAirport = (string)dr["DepartureAirport"];
                    li.Add(dmr);
                }
                _listDomesticRoute = li.ToArray();
            }
            return _listDomesticRoute;
        }
    }
}
